package com.yhsoft.bill.mapper;

import com.yhsoft.bill.controller.response.*;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface BillReportMapper {
    @Select("select a.order_id as orderNo , a.distributor_id as venderOrderNo,b.goods_name,b.goods_type,c.sku_name ,d.sku_quantity\" +\n" +
            "            \",d.sku_price as goodsPrice,CAST((d.sku_quantity * d.sku_price) AS DECIMAL(9, 2)) as totlePrice,e.pay_time,f.company_name,f.company_name as companyZT\n" +
            "             from buyer_order a left join g_goods_info b on a.distributor_id=b.id\n" +
            "                  left join  g_good_sku c on a.order_id=c.goods_id\n" +
            "                  left join buyer_cart_sku d  on d.goods_id=c.goods_id\n" +
            "                  left join bill_vender_yszk_mx e on a.order_id =e.id\n" +
            "                  left join  x_company_info f on a.distributor_id=f.id")
    List<SysYckLogOutVo> select(Class<SysYckLogOutVo> sysYckLogOutVoClass);


    @Select("select b.id,b.pay_by,b.type,b.pay_amount,b.voucher, b.pay_time from bill_sys_yszk_mx b")
    List<SysYszkMxOutVo> selectOut(Class<SysYszkMxOutVo> sysYszkMxOutVoClass);


    @Select("select a.order_id as OrderNo,a.distributor_id as VenderOrderNo,b.goods_name as GoodsName,a.total_price, b.goods_type as GoodsType,c.company_name,\n" +
            "                    c.company_name as companyZT from\n" +
            "                     buyer_order a\n" +
            "                         left join g_goods_info b on a.order_id=b.id\n" +
            "                         left join  x_company_info c on a.distributor_id=c.id")
    List<SysYckLogOutVo> selectBu(Class<SysYckLogOutVo> sysYckLogOutVoClass);


    @Select("select a.id,a.first_batch_num,a.second_bantch_num,a.ys_amount,a.create_time,a.pay_amount as YsAmount,\n" +
            "            a.voucher as Voucher ,a.pay_by as PayBy,a.pay_time from bill_saler_yszk_mx a")
    List<SalerYszkMxOutVo> selectAu(Class<SalerYszkMxOutVo> salerYszkMxOutVoClass);

    @Select("select a.id,b.customer_name,a.total_ys_amount,a.need_pay_amount,a.total_pay_amount,\n" +
            "            a.create_time from\n" +
            "                              bill_saler_yszk a left join baic_customer_info b on a.company_id=b.company_id where a.company_id = #{companyId}")
    List<SalerYszkOutVo> selectCu(Class<SalerYszkOutVo> salerYszkOutVoClass, Integer companyId);


    @Select("        SELECT\n" +
            "            a.order_id AS orderNo,\n" +
            "            a.order_id AS venderOrderNo,\n" +
            "            d.goods_name,\n" +
            "            d.goods_type,\n" +
            "            d.vendor_id,\n" +
            "            CONCAT( c.sku_name, \"-\", c.sku_info ) AS skuName,\n" +
            "            c.sku_quantity,\n" +
            "            c.sku_price AS goodsPrice,\n" +
            "            CAST((\n" +
            "                c.sku_quantity * c.sku_price\n" +
            "                ) AS DECIMAL ( 9, 2 )) AS totlePrice,\n" +
            "            b.NAME,\n" +
            "            b.mobile,\n" +
            "            b.address,\n" +
            "            e.company_name,\n" +
            "            e.company_name AS companyZt,\n" +
            "            f.nick_name,\n" +
            "            a.*\n" +
            "        FROM\n" +
            "            buyer_order a\n" +
            "                LEFT JOIN buyer_address b ON a.address_id = b.id\n" +
            "                LEFT JOIN buyer_cart_sku c ON a.cart_id = c.cart_id\n" +
            "                LEFT JOIN g_goods_info d ON c.goods_id = d.id\n" +
            "                LEFT JOIN x_company_info e ON a.distributor_id = e.id\n" +
            "                LEFT JOIN buyer_user f ON a.user_id = f.id" +
            "   where a.order_status = 0 " +
            "   AND a.distributor_id = #{companyId}" +
            "   AND a.order_type <> 'DY' ")
    List<SalerXhLogOutVo> selectDu(Class<SalerXhLogOutVo> salerXhLogOutVoClass, Integer companyId);
}
